package com.dyrj.common;

import com.dyrj.base.system.user.model.SysUser;
import com.dyrj.constant.SysFrameConst;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class BaseController {
    protected Logger logger = LoggerFactory.getLogger(getClass());

    protected SysUser getUser() {
        Subject subject = SecurityUtils.getSubject();
        // 保存用户信息进session
        SysUser sysUser = (SysUser)subject.getSession().getAttribute(SysFrameConst.SYSTEM_USER);
        return sysUser;
    }

    protected Long getUserId() {
        return getUser().getId();
    }

    protected String getUsername(){
        return getUser().getLoginUser();
    }

    protected Long getDeptId() {
        return getUser().getDeptid();
    }
    protected Long getTenantid() {
        return getUser().getTenantid();
    }
}
